[Embed(source="images/success.png")]private var successIcon:Class;
[Embed(source="images/error.png")]private var errorIcon:Class;
import mx.collections.*;
import mx.controls.*;
import mx.events.*;
import mx.managers.PopUpManager;
import mx.rpc.events.FaultEvent;
import mx.rpc.events.ResultEvent;

public var entity:String="";
public var entityName:String="";

public var program:String="";
public var branch:String="";
public var specialization:String="";

public var process:String="";
public var semester:String="";
public var semesterName:String="";

public var programCourseKey:String="";
public var ssd:String="";
public var sed:String="";
public var activityCode:String="";
public var actvitySeq:String="";
public var activityStatus:String="";
[Bindable] public var buttonFunction:Function;

[Bindable] private var xmldata_activityList:XML;

public var url_DNS:String ="";
    	[Bindable] public var urlStartActivityList:String = "";


//This function Gives alert on confirmation 

public function confirmFunction():void 
{   
					url_DNS = commonFunction.getConstants('url');
					//Check CourseMaster Controller: Amir Code
		    		urlStartActivityList = url_DNS+"/startActivity/startProcessActivity.htm";
		    		
	var param:Object=new Object();
	param["entityId"]=entity;
	
	param["entityName"]=entityName;
	
	param["programId"]=program;
	param["branchId"]=branch;
	param["specializationId"]=specialization;
	
	param["programName"]=programforConfirmWindow.text;
	param["branchName"]=branchforConfirmWindow.text;
	param["specializationName"]=specilizationforConfirmWindow.text;
	
	
	
	param["processId"]=process;
	param["semesterId"]=semester;
	param["semesterName"]=semesterName;
	
	param["programCourseKey"]=programCourseKey;
	param["semesterStartDate"]=ssd;
	param["semesterEndDate"]=sed;
	
	param["activityCode"]=activityCode;
	param["activitySequence"]=actvitySeq;
	param["activityStatus"]=activityStatus;
	
	httpXmlStartActivityList.send(param);
	//Alert.show((resourceManager.getString('Messages','activitySubmittedSuccessfully')),(resourceManager.getString('Messages','success')),0,null,null,successIcon);
	
	closeConfirmWindow();
}

 private function startActivityResultHandler(event:ResultEvent):void{
        xmldata_activityList=event.result as XML;
       // Alert.show("Return Value"+xmldata_activityList);
               
				var total:String="";
				var correct:String="";
        		var reject:String="";
        		var error:String="";
        		var isComplete:String="";
     //  Alert.show('coming in result activity start'+xmldata_activityList);
        var coutResult:ArrayCollection=new ArrayCollection();
        for each(var o:Object in xmldata_activityList.count){
        	coutResult.addItem({total:o.total,correct:o.correct,reject:o.rejected,error:o.error});
        }

        		
       for each(var o:Object in coutResult){
        		total=o.total;
        		correct=o.correct;
        		reject=o.reject;
        		error=o.error;
        		isComplete=o.activityCompleted;
        	}
        	
       if(total==""){
       	
        Alert.show("Database Inconsistency:System Failure","Error",0,null,null,errorIcon); 	
       		 
       }else{
       			var sts:String="";
       		 if(isComplete=="true")	{
       		 	sts="Activity Completed";
       		 }else{
       		 	sts="Activity Not Completed";
       		 }
           Alert.show("Total Records ="+" "+total+"\n"+"Records Processed Correctly ="+" "+correct+"\n"+"Records Rejected ="+" "+reject+"\n"+"Records Give Error ="+" "+error+"\n"+sts,"Result",4,null,onStart,successIcon);
        }
        
        //specializationCombo.dataProvider=xmldata_activityList.activity.value;
    }
    
    public function onStart(event:CloseEvent):void{
    	buttonFunction.call();
    }
    
 private function faultHandler(event:FaultEvent):void{
       //  mx.controls.Alert.show(event.fault.message,getString('errorInResult'));
    }
    
//This function Close popup window on click of cancel button on window
public function cancelConfirmWindow():void 
{
	closeConfirmWindow();
}

//This function Close popup window on click of close sign at corner on window
public function closeConfirmWindow():void
{
	PopUpManager.removePopUp(this);			
}
  
   private function initializeForEsc(evt:KeyboardEvent):void
   {
    if (evt.keyCode == Keyboard.ESCAPE)
    {
    	closeConfirmWindow();
    }
  }